package com.keith.asteria.controller.login;

import com.keith.asteria.controller.remoteApi.RemoteSysUserApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import system.SysUser;

import java.util.Map;

/**
 * @ClassName LoginController
 * @Author chenli
 * @Time 2018/11/9
 **/
@Controller
@RequestMapping("/login")
public class LoginController {

	@Autowired
	RemoteSysUserApi userApi;

	@GetMapping("/login_toLogin")
	public Object login_toLogin() {
		return "pages/login.html";
	}


	@GetMapping("/login_toRegist")
	public Object login_toRegist() {
		return "pages/user/register.html";
	}

	@PostMapping("/login_regSave")
	@ResponseBody
	public Object login_regSave(SysUser sysUser) {
		Object object = userApi.userSave(sysUser);
		return object;
	}

	@PostMapping("/login_userLogin")
	public Object login_userLogin(String username, String password) {
		SysUser user = new SysUser();
		user.setUsername(username);
		user.setPassword(password);
		Map<String, Object> resp = userApi.userLogin(user);
		return "pages/system/welcome.html";

	}



}
